package com.ruoyi.channel.enums;

import cn.hutool.core.util.ObjectUtil;
import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 渠道/产品计价类型
 */
@Getter
public enum PageTypeEnum {

    AUTH_LIST("auth_list", "留资-匹配"),
    AUTH_DOWNLOAD("auth_download", "留资-下载"),
    LIST("list", "公众号"),
    DOWNLOAD("download", "下载"),
    AUTH("auth", "留资-公众号"),
    APP("app", "留资-静推"),
    APPLET("applet", "留资-简易版"),
    H5_TO_MINI("h5_to_mini", "H5-->mini"),
    ;

    private String value;
    private String name;

    PageTypeEnum(String value, String name){
        this.value = value;
        this.name = name;
    }

    public static List<Map<String, String>> getPageTypeMapList(){
        List<Map<String, String>> resultList = new ArrayList<>();
        for (PageTypeEnum pageTypeEnum : values()) {
            Map<String, String> itemMap = new HashMap<>();
            itemMap.put("key", pageTypeEnum.getName());
            itemMap.put("value", String.valueOf(pageTypeEnum.getValue()));
            resultList.add(itemMap);
        }
        return resultList;
    }

    public static String getNameByValue(String pageType) {
        for (PageTypeEnum pageTypeEnum : values()) {
            if (ObjectUtil.equals(pageType, pageTypeEnum.getValue())){
                return pageTypeEnum.getName();
            }
        }
        return String.valueOf(pageType);
    }

}
